-
Notifications
You must be signed in to change notification settings - Fork 292
CP-308800: Dynamic control of firewalld service - part 1 #6629
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CP-308800: Dynamic control of firewalld service - part 1 #6629
Conversation
46f6446
to
6fbb10e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I really like this idea, it's similar to what I had in mind to remake the port management feature for the SDN, which seems very easy to add with this PR. I think it can be made even better to reduce complexity in the users' side
6fbb10e
to
ad68294
Compare
ocaml/xapi/firewall.ml
Outdated
| Xapi_insecure -> | ||
("80", "TCP") | ||
| _ -> | ||
failwith | ||
"service_type_to_port_and_protocol: Unsupported service type for \ | ||
iptables" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can be moved to line 48, and the other service can be implemented, it shouldn't be difficult to look up the port and protocol.
Doesn't SSH auto mode need this to work?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The other services will be implemented in later PRs.
For SSH, I'm considering if we should implement dynamic firewall control in xapi, as SSH service can be changed not only by xapi, but also by xapi-monitor-ssh, and systemd command directly.
Maybe we can just simply leave it opening.
Another option is to add the firewall-cmd to ExecStartPre
and ExecStopPost
of sshd systemd definition file.
What's your thought? @psafont
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For SSH, I'm considering if we should implement dynamic firewall control in xapi, as SSH service can be changed not only by xapi, but also by xapi-monitor-ssh, and systemd command directly.
xapi-monitor-ssh needs to work even if xapi is not working, but there are rpc functions exposed in xapi that need to do the same. I think it makes sense that xapi uses this interface to open and close the SSH port; and ideally xapi-monitor-ssh would be done in ocaml and use the same library, otherwise it will need to duplicate the functionality somehow
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
xapi-monitor-ssh
is written in Python.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the easiest way to dynamic update sshd port is to add ExecStartPre and ExecStopPost to systemd definition file, as both xapi and ssh-monitor-ssh calls systemd to manage sshd. This can avoid the duplication.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know the exact requirements from xenserver, but as far as I'm aware:
- Switching of and on a single system instead of 2 means there's less chance of getting recovery and updates wrong. This means that I prefer a solution that blocks the port to the solution that blocks the ports and starts and stops the ssh daemon.
- Sharing a module of code to open a close ports between different daemons means that it only needs one set of sets instead.
- Modifying upstream service files and code increases maintenance costs, and as such I would avoid using ExecStartPre and ExecStopPost
So my preference would be to use this module both on xapi
and xapi-monitor-ssh
as the single mechanism to interrupt and enable access to SSH. But as I said previously, this is without knowing xenserver's feature requirements
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The requirement comes from engineers instead of customers. It's to avoid the difference between a port being firewalled and not having a listening service when doing the port scan.
xapi-monitor-ssh
is written by Python. I don't think we should rewrite it with Ocaml to use the same firewall module (or do you mean call this module in the Python code?). If we have to implement it in both xapi
and xapi-monitor-ssh
, I think we can just implement it in the existing Python code.
Only the 2 last comments are important, the others are cosmetic |
cb836e3
to
bed29a2
Compare
bed29a2
to
4479248
Compare
4479248
to
3183690
Compare
1bedacb
to
58c2b22
Compare
Signed-off-by: Bengang Yuan <[email protected]>
Signed-off-by: Bengang Yuan <[email protected]>
58c2b22
to
e682b80
Compare
4c9f4a4
into
xapi-project:feature/dynamic-firewalld-control
Implement dynamic control of firewalld service.
The first PR defines dynamic firewall control function, variable, and the http service's dynamic control.
The other services's dynamic control will be in the later PR.